{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# path = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/loss/classification/288new'#指定文件所在路径\n",
    "# path = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/loss/completion1227'\n",
    "path = '/Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227'\n",
    "filetype ='.csv'#指定文件类型\n",
    "def get_filename(path, filetype):\n",
    "    name =[]\n",
    "    xlsx_name = []\n",
    "    for root,dirs,files in os.walk(path):\n",
    "        for i in files:\n",
    "            if filetype in i:\n",
    "                print(i)\n",
    "                name.append(i)\n",
    "                csv2xlsx(path, i)\n",
    "    return name#输出由有‘.csv’后缀的文件名组成的列表\n",
    "\n",
    "def csv2xlsx(path, filename):\n",
    "    f_in = os.path.join(path, filename)\n",
    "    df = pd.read_csv(f_in)\n",
    "    xlsx_name = filename[:-3]+'xlsx'\n",
    "    path_new = path + '/complement_plot_excel'\n",
    "    if not os.path.exists(path_new):\n",
    "        os.makedirs(path_new)\n",
    "    f_out = os.path.join(path_new, xlsx_name)\n",
    "    df.to_excel(f_out)\n",
    "#     df = pd.read_csv(f_in, nrows=2016)\n",
    "#     for chunk in pd.read_csv(f_in, chunksize=2016):\n",
    "#         xlsx_name = filename[:-3]+'xlsx'\n",
    "#         path_new = path + '/pretrain_loss_excel'\n",
    "#         if not os.path.exists(path_new):\n",
    "#             os.makedirs(path_new)\n",
    "#         f_out = os.path.join(path_new, xlsx_name)\n",
    "#         chunk.to_excel(f_out)\n",
    "    print(f\"Transfer {filename} to {f_out}!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "complement_K6_C36_i216.csv\n",
      "Transfer complement_K6_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C36_i216.xlsx!\n",
      "complement_K1_C36_i216.csv\n",
      "Transfer complement_K1_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C36_i216.xlsx!\n",
      "FC_complement_C12_i120.csv\n",
      "Transfer FC_complement_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C12_i120.xlsx!\n",
      "complement_K2_C36_i48.csv\n",
      "Transfer complement_K2_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C36_i48.xlsx!\n",
      "FC_complement_C12_i48.csv\n",
      "Transfer FC_complement_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C12_i48.xlsx!\n",
      "complement_K12_C12_i48.csv\n",
      "Transfer complement_K12_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C12_i48.xlsx!\n",
      "complement_K1_C12_i48.csv\n",
      "Transfer complement_K1_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C12_i48.xlsx!\n",
      "complement_K2_C12_i120.csv\n",
      "Transfer complement_K2_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C12_i120.xlsx!\n",
      "complement_K24_C36_i120.csv\n",
      "Transfer complement_K24_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C36_i120.xlsx!\n",
      "complement_K12_C36_i120.csv\n",
      "Transfer complement_K12_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C36_i120.xlsx!\n",
      "complement_K2_C36_i120.csv\n",
      "Transfer complement_K2_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C36_i120.xlsx!\n",
      "complement_K1_C12_i216.csv\n",
      "Transfer complement_K1_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C12_i216.xlsx!\n",
      "complement_K6_C12_i216.csv\n",
      "Transfer complement_K6_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C12_i216.xlsx!\n",
      "FC_complement_C36_i120.csv\n",
      "Transfer FC_complement_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C36_i120.xlsx!\n",
      "complement_K12_C12_i120.csv\n",
      "Transfer complement_K12_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C12_i120.xlsx!\n",
      "complement_K12_C36_i48.csv\n",
      "Transfer complement_K12_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C36_i48.xlsx!\n",
      "FC_complement_C36_i48.csv\n",
      "Transfer FC_complement_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C36_i48.xlsx!\n",
      "complement_K2_C12_i48.csv\n",
      "Transfer complement_K2_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C12_i48.xlsx!\n",
      "complement_K1_C36_i48.csv\n",
      "Transfer complement_K1_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C36_i48.xlsx!\n",
      "complement_K24_C12_i120.csv\n",
      "Transfer complement_K24_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C12_i120.xlsx!\n",
      "complement_K2_C12_i216.csv\n",
      "Transfer complement_K2_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C12_i216.xlsx!\n",
      "complement_K1_C36_i120.csv\n",
      "Transfer complement_K1_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C36_i120.xlsx!\n",
      "complement_K6_C36_i120.csv\n",
      "Transfer complement_K6_C36_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C36_i120.xlsx!\n",
      "FC_complement_C12_i216.csv\n",
      "Transfer FC_complement_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C12_i216.xlsx!\n",
      "complement_K6_C36_i48.csv\n",
      "Transfer complement_K6_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C36_i48.xlsx!\n",
      "complement_K24_C12_i48.csv\n",
      "Transfer complement_K24_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C12_i48.xlsx!\n",
      "complement_K12_C36_i216.csv\n",
      "Transfer complement_K12_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C36_i216.xlsx!\n",
      "complement_K24_C36_i216.csv\n",
      "Transfer complement_K24_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C36_i216.xlsx!\n",
      "complement_K6_C12_i120.csv\n",
      "Transfer complement_K6_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C12_i120.xlsx!\n",
      "complement_K1_C12_i120.csv\n",
      "Transfer complement_K1_C12_i120.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K1_C12_i120.xlsx!\n",
      "FC_complement_C36_i216.csv\n",
      "Transfer FC_complement_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/FC_complement_C36_i216.xlsx!\n",
      "complement_K2_C36_i216.csv\n",
      "Transfer complement_K2_C36_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K2_C36_i216.xlsx!\n",
      "complement_K24_C12_i216.csv\n",
      "Transfer complement_K24_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C12_i216.xlsx!\n",
      "complement_K24_C36_i48.csv\n",
      "Transfer complement_K24_C36_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K24_C36_i48.xlsx!\n",
      "complement_K6_C12_i48.csv\n",
      "Transfer complement_K6_C12_i48.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K6_C12_i48.xlsx!\n",
      "complement_K12_C12_i216.csv\n",
      "Transfer complement_K12_C12_i216.csv to /Users/gengyunxin/Documents/项目/traffic_model/TVTS_9.28/finetune/test_result_all/complement_plot_1227/complement_plot_excel/complement_K12_C12_i216.xlsx!\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['complement_K6_C36_i216.csv',\n",
       " 'complement_K1_C36_i216.csv',\n",
       " 'FC_complement_C12_i120.csv',\n",
       " 'complement_K2_C36_i48.csv',\n",
       " 'FC_complement_C12_i48.csv',\n",
       " 'complement_K12_C12_i48.csv',\n",
       " 'complement_K1_C12_i48.csv',\n",
       " 'complement_K2_C12_i120.csv',\n",
       " 'complement_K24_C36_i120.csv',\n",
       " 'complement_K12_C36_i120.csv',\n",
       " 'complement_K2_C36_i120.csv',\n",
       " 'complement_K1_C12_i216.csv',\n",
       " 'complement_K6_C12_i216.csv',\n",
       " 'FC_complement_C36_i120.csv',\n",
       " 'complement_K12_C12_i120.csv',\n",
       " 'complement_K12_C36_i48.csv',\n",
       " 'FC_complement_C36_i48.csv',\n",
       " 'complement_K2_C12_i48.csv',\n",
       " 'complement_K1_C36_i48.csv',\n",
       " 'complement_K24_C12_i120.csv',\n",
       " 'complement_K2_C12_i216.csv',\n",
       " 'complement_K1_C36_i120.csv',\n",
       " 'complement_K6_C36_i120.csv',\n",
       " 'FC_complement_C12_i216.csv',\n",
       " 'complement_K6_C36_i48.csv',\n",
       " 'complement_K24_C12_i48.csv',\n",
       " 'complement_K12_C36_i216.csv',\n",
       " 'complement_K24_C36_i216.csv',\n",
       " 'complement_K6_C12_i120.csv',\n",
       " 'complement_K1_C12_i120.csv',\n",
       " 'FC_complement_C36_i216.csv',\n",
       " 'complement_K2_C36_i216.csv',\n",
       " 'complement_K24_C12_i216.csv',\n",
       " 'complement_K24_C36_i48.csv',\n",
       " 'complement_K6_C12_i48.csv',\n",
       " 'complement_K12_C12_i216.csv']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_filename(path, filetype=filetype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:pytorch1.6.0] *",
   "language": "python",
   "name": "conda-env-pytorch1.6.0-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
